package com.dkm.biz.ou.repository.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.repository.AbstractRepository;
import com.dkm.biz.ou.domain.ShopAuth;
import com.dkm.biz.ou.repository.ShopAuthRepository;
import com.dkm.biz.ou.persistence.dao.ShopAuthQueryDao;
import com.dkm.biz.ou.persistence.entity.ShopAuthPo;

/**
 * 对象功能:t_ou_shop_auth Repository接口的实现类
 * 开发公司:dkm.com
 * 开发人员:ZHH
 * 创建时间:2017-07-25 10:59:54
 */
@Repository
public class ShopAuthRepositoryImpl extends AbstractRepository<String, ShopAuthPo,ShopAuth> implements ShopAuthRepository{
	  
	@Resource
	private  ShopAuthQueryDao shopAuthQueryDao;

	public ShopAuth newInstance() {
		ShopAuthPo po = new ShopAuthPo();
		ShopAuth shopAuth = SpringHelper.getBean(ShopAuth.class);
		shopAuth.setData(po);
		return shopAuth;
	}

	public ShopAuth newInstance(ShopAuthPo po) {
		ShopAuth shopAuth = SpringHelper.getBean(ShopAuth.class);
		shopAuth.setData(po);
		return shopAuth;
	} 
	
	@Override
	protected IQueryDao<String, ShopAuthPo> getQueryDao() {
		return shopAuthQueryDao;
	}

	@Override
	public ShopAuthPo findByShopId(String shopId) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("whereSql", "shop_id_='"+shopId+"'");
		List<ShopAuthPo> shopAuthPos =  shopAuthQueryDao.findAll(params);
		if(shopAuthPos.size() > 0){
			return shopAuthPos.get(0);
		}
		return null;
	}
	
}
